<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\JxtArticle;
use App\Models\JxtBanner;
use App\Models\JxtSpecialist;

class IndexController extends Controller
{
    public function index(): \Illuminate\Http\JsonResponse
    {
        $banner = JxtBanner::where('status', JxtBanner::STATUS_SHOW)->get();
        $theme = JxtArticle::where(['category_id' => 7, 'status' => JxtArticle::STATUS_SHOW])
            ->take(4)
            ->orderBy('id', 'desc')
            ->get();
        $service = JxtArticle::where(['category_id' => 8, 'status' => JxtArticle::STATUS_SHOW])
            ->take(4)
            ->orderBy('id', 'desc')
            ->get();
        $specialist = JxtSpecialist::where('status', JxtArticle::STATUS_SHOW)
            ->take(6)
            ->orderBy('id', 'desc')
            ->get();

        return response()->json([
            'message' => 'success',
            'code' => 0,
            'status_code' => 200,
            'data' => ['banner' => $banner, 'theme' => $theme, 'service' => $service, 'specialist' => $specialist]
        ]);
    }
}
